﻿
var invoiceTemplateCreator = function ($scope, $modal) {


    // DATA INITIALIZATION
    $scope.ImageRotation = [
        { name: 'No Rotated', rotation: '' },
        { name: 'Rotate-90', rotation: 'fa-rotate-90' },
        { name: 'Rotate-180', rotation: 'fa-rotate-180' },
        { name: 'Rotate-270', rotation: 'fa-rotate-270' },
        { name: 'Flip-horizontal', rotation: 'fa-flip-horizontal' },
        { name: 'Flip-vertical', rotation: 'fa-flip-vertical' }
    ];


    $scope.logoSize = [
        { name: 'Size 1x', size: 'fa-stack-1x' },
        { name: 'Size 2x', size: 'fa-stack-2x' }
    ];


    //COMPANY VARIABLES
    $scope.companyInfo = [
        { companyName: "Company Name" },
        { companyAddress: "455 Foggy Heights" },
        { stateZipCode: "AZ 85004, US" },
        { telephone: "(602) 519-0450" },
        { website: "company@example.com" }];

    //LOGO VARIABLES
    $scope.title = "Angular Logo Designer";
    $scope.selected = "fa fa-ban";
    $scope.imageBackGround = "fa fa-camera ";
    $scope.imageSrc = "App/Images/placeholderSquare.svg";
    $scope.clipArt = false;
    $scope.image = true;
    $scope.hasImage = false;
    $scope.imageName = "";
    $scope.logoText = "Logo name optional";
    $scope.imagebackgroundColor = { color: 'blue' };
    $scope.clipArtColor = { color: 'red' };
    $scope.logoRotation = $scope.ImageRotation[0];
    $scope.backgroundRotation = $scope.ImageRotation[0];
    $scope.ImageLogoSize = $scope.logoSize[1];
    $scope.ImageBgLogoSize = $scope.logoSize[0];

 


   //MODAL WINDOW    BRINGS THE LOGO RESULT IMAGE ON RESULT
    $scope.open = function () {

        var modalInstance = $modal.open({
            templateUrl: '/App/Templates/logo-designer.html',
            controller: 'logoDesignerController'
        });

        modalInstance.result.then(function(selectedItem) {
            if (selectedItem.length == 8) {            
            $scope.image = false;
            $scope.clipArt = true;
            $scope.selected = selectedItem[0].src;
            $scope.imageBackGround = selectedItem[1].src;
            $scope.imagebackgroundColor = selectedItem[2].color;
            $scope.clipArtColor = selectedItem[3].color;
            $scope.logoRotation = selectedItem[4].rotation;
            $scope.backgroundRotation = selectedItem[5].rotation;
            $scope.ImageLogoSize = selectedItem[6].size;
            $scope.ImageBgLogoSize = selectedItem[7].size;
            }
            else {
                $scope.clipArt = false;
                $scope.imageSrc = selectedItem;
                $scope.image = true;
            }
    
        
        }, function () {
        });


    };

    $scope.openCompanyInfo = function () {

        var modalInstance = $modal.open({
            templateUrl: '/App/Templates/company-info.html',
            controller: 'companyInfoController'
        });

        modalInstance.result.then(function(selectedItem) {
            if (selectedItem.length == 8) {            
            $scope.image = false;
            $scope.clipArt = true;
            $scope.imageSrc = selectedItem[0].src;
            $scope.imageBackGround = selectedItem[1].src;
            $scope.imagebackgroundColor = selectedItem[2].color;
            $scope.clipArtColor = selectedItem[3].color;
            $scope.logoRotation = selectedItem[4].rotation;
            $scope.backgroundRotation = selectedItem[5].rotation;
            $scope.ImageLogoSize = selectedItem[6].size;
            $scope.ImageBgLogoSize = selectedItem[7].size;
            }
            else {
                $scope.clipArt = false;
                $scope.imageSrc = selectedItem;
                $scope.image = true;
            }
    
        
        }, function () {
        });


    };

};

